package com.bokee.archerwq.lab.wife;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;

public class ColumnToRow {

	public static void main(String[] args) throws Exception {
		PrintWriter pw = new PrintWriter(new FileWriter(
				"E:/data/2011-8/2011-nb(8)-rows.txt"));

		for (int i = 32; i <= 138; i++) {
			String fileName = "E:/data/2011-8/2011-nb(8)-" + i + ".txt";
			try {
				BufferedReader br = new BufferedReader(new FileReader(fileName));
				pw.print(i + ",");
				String line = null;
				while ((line = br.readLine()) != null && !"".equals(line)) {
					line = new String(line.getBytes("GBK"), "UTF-8");
					System.out.println(">>>" + line);
					line = line.substring(0, line.length() - 1);
					String data = line.substring(line.lastIndexOf(",") + 1);
					pw.print(data + ",");
				}
				br.close();
				pw.println("");
			} catch (FileNotFoundException e) {
				System.out.println("not exist: " + fileName);
				continue;
			}
		}
		pw.flush();
		pw.close();
	}

}
